<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class check_service{
	private $CI;
	function __construct() { 
		$this->CI = &get_instance();
		$this->CI -> load -> model("Dic_model");	
		$this->CI -> load -> model("Admin_model");	
		$this->CI->load->model("Academia_job_model");
		$this->CI->load->model("Academia_job_kh_model");
		$this ->CI-> load -> model("Subject_platform_model");	
		$this ->CI-> load -> model("Subject_platform_kh_model");	
		$this->CI->load->model("Academic_report_model");
		$this->CI->load->model("Academic_report_kh_model");
		$this->CI->load->model("Audit_model");
		$this->CI->load->model("Awards_model");
		$this->CI->load->model("Awards_kh_model");
		$this->CI->load->model("Communication_model");
		$this->CI->load->model("Communication_kh_model");
		$this->CI->load->model("Horizontal_project_model");
		$this->CI->load->model("Horizontal_project_kh_model");
		$this->CI->load->model("Monograph_model");
		$this->CI->load->model("Monograph_kh_model");
		$this->CI->load->model("Paper_model");
		$this->CI->load->model("Paper_kh_model");
		$this->CI->load->model("Patent_data_model");
		$this->CI->load->model("Patent_model");
		$this->CI->load->model("Patent_kh_model");
		$this->CI->load->model("Research_report_model");
		$this->CI->load->model("Research_report_kh_model");
		$this->CI->load->model("Science_conversion_model");
		$this->CI->load->model("Science_conversion_kh_model");
		$this->CI->load->model("Technical_standard_model");
		$this->CI->load->model("Technical_standard_kh_model");
		$this->CI->load->model("Vertical_project_model");
		$this->CI->load->model("Vertical_project_kh_model");
		$this->CI->load->model("User_model");
	}

	/**  
	* 新增一条成果考核表记录
	* @access public 
	* @param  $type  成果类型
	* @param  $data_id  成果id
	*/  
	function addCheckDetail($type,$data_id){	
		$host_url = headerurl()."/"."zjipc_kycg/";
		switch ($type) {
			case ResultsType::First[XPHEnum::Value]://论文
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::First[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_paper.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::First[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_paper.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::First[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_paper.id');
				$connar['where'] = $this->CI->sqlEscape('db_paper.id=?? ', array($data_id));
				$data=$this->CI->Paper_model->get_single_full($connar);
				// echo $this->CI->db->last_query();
				break;
			
			case ResultsType::Second[XPHEnum::Value]://专著
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Second[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_monograph.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Second[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_monograph.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Second[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_monograph.id');
				$connar['where'] = $this->CI->sqlEscape('db_monograph.id=?? ', array($data_id));
				$data=$this->CI->Monograph_model->get_single_full($connar);
				// $data=$this->CI->Monograph_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Third[XPHEnum::Value]://专利
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Third[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_patent.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Third[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_patent.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Third[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_patent.id');
				$connar['where'] = $this->CI->sqlEscape('db_patent.id=?? ', array($data_id));
				$data=$this->CI->Patent_model->get_single_full($connar);
				// $data=$this->CI->Patent_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Fourth[XPHEnum::Value]://获奖
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) main_complete,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Fourth[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_awards.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Fourth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_awards.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Fourth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_awards.id');
				$connar['where'] = $this->CI->sqlEscape('db_awards.id=?? ', array($data_id));
				$data=$this->CI->Awards_model->get_single_full($connar);
				// $data=$this->CI->Awards_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Fifth[XPHEnum::Value]://研究报告
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Fifth[XPHEnum::Value].' and db_user.is_del=0  GROUP BY db_author.data_id ) author','author.data_id=db_research_report.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Fifth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_research_report.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Fifth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_research_report.id');
				$connar['where'] = $this->CI->sqlEscape('db_research_report.id=?? ', array($data_id));
				$data=$this->CI->Research_report_model->get_single_full($connar);
				// $data=$this->CI->Research_report_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Sixth[XPHEnum::Value]://技术标准
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) completeor,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Sixth[XPHEnum::Value].' and db_user.is_del=0  GROUP BY db_author.data_id ) author','author.data_id=db_technical_standard.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Sixth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_technical_standard.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Sixth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_technical_standard.id');
				$connar['where'] = $this->CI->sqlEscape('db_technical_standard.id=?? ', array($data_id));
				$data=$this->CI->Technical_standard_model->get_single_full($connar);
				// $data=$this->CI->Technical_standard_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Seventh[XPHEnum::Value]://纵向
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) head_name,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Seventh[XPHEnum::Value].' and db_user.is_del=0  GROUP BY db_author.data_id ) author','author.data_id=db_vertical_project.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Seventh[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_vertical_project.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Seventh[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_vertical_project.id');
				$connar['where'] = $this->CI->sqlEscape('db_vertical_project.id=?? ', array($data_id));
				$data=$this->CI->Vertical_project_model->get_single_full($connar);
				// $data=$this->CI->Vertical_project_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Eighth[XPHEnum::Value]://横向
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) head_name,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Eighth[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_horizontal_project.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Eighth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_horizontal_project.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Eighth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_horizontal_project.id');
				$connar['where'] = $this->CI->sqlEscape('db_horizontal_project.id=?? ', array($data_id));
				$data=$this->CI->Horizontal_project_model->get_single_full($connar);
				// $data=$this->CI->Horizontal_project_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Ninth[XPHEnum::Value]://转化科技
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) head_name,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Ninth[XPHEnum::Value].' and db_user.is_del=0  GROUP BY db_author.data_id ) author','author.data_id=db_science_conversion.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Ninth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_science_conversion.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Ninth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_science_conversion.id');
				$connar['where'] = $this->CI->sqlEscape('db_science_conversion.id=?? ', array($data_id));
				$data=$this->CI->Science_conversion_model->get_single_full($connar);
				// $data=$this->CI->Science_conversion_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Tenth[XPHEnum::Value]://学术交流会
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author_name,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Tenth[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_communication.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Tenth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_communication.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Tenth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_communication.id');
				$connar['where'] = $this->CI->sqlEscape('db_communication.id=?? ', array($data_id));
				$data=$this->CI->Communication_model->get_single_full($connar);
				unset($data['author_name']);
				// $connar['join'][0]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Tenth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_communication.id');
				// $connar['join'][1]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Tenth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_communication.id');
				// $connar['where'] = $this->CI->sqlEscape('db_communication.id=?? ', array($data_id));
				// $data=$this->CI->Communication_model->get_single_full($connar);
				// $data=$this->CI->Communication_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Eleventh[XPHEnum::Value]://学术报告
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author_name,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Eleventh[XPHEnum::Value].'  and db_user.is_del=0 GROUP BY db_author.data_id ) author','author.data_id=db_academic_report.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Eleventh[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_academic_report.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Eleventh[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_academic_report.id');
				$connar['where'] = $this->CI->sqlEscape('db_academic_report.id=?? ', array($data_id));
				$data=$this->CI->Academic_report_model->get_single_full($connar);
				unset($data['author_name']);
				// $connar['join'][0]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Tenth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_academic_report.id');
				// $connar['join'][1]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Tenth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_academic_report.id');
				// $connar['where'] = $this->CI->sqlEscape('db_academic_report.id=?? ', array($data_id));
				// $data=$this->CI->Academic_report_model->get_single_full($connar);
				// $data=$this->CI->Academic_report_model->get_single(array('id'=>$data_id));
				break;
			
			case ResultsType::Twelfth[XPHEnum::Value]://兼职
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) name,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,group_concat(db_author.identity  ORDER BY db_author.id ASC) identity,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Twelfth[XPHEnum::Value].' and db_user.is_del=0  GROUP BY db_author.data_id ) author','author.data_id=db_academia_job.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Twelfth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_academia_job.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Twelfth[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_academia_job.id');
				$connar['where'] = $this->CI->sqlEscape('db_academia_job.id=?? ', array($data_id));
				$data=$this->CI->Academia_job_model->get_single_full($connar);
				// $data=$this->CI->Academia_job_model->get_single(array('id'=>$data_id));
				break;
			case ResultsType::Thirteen[XPHEnum::Value]://学科平台
				$connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY db_author.id ASC) author,group_concat( db_user.usercode ORDER BY db_author.id ASC ) authorcode,data_id FROM db_author left join db_user on db_user.id = db_author.author_id and db_user.username=db_author.author_name WHERE db_author.type = '.ResultsType::Thirteen[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_subject_platform.id');
				$connar['join'][1]=array('(select group_concat(db_file.src ORDER BY db_file.id ASC separator \',\' ) AS imgurl, db_file.data_id AS img_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Thirteen[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::Img[XPHEnum::Value].' )) GROUP BY db_file.data_id) img_view','img_view.img_data_id=db_subject_platform.id');
				$connar['join'][2]=array('(select CONCAT(\''.$host_url .'\',group_concat(db_file.src ORDER BY db_file.id ASC SEPARATOR \','.$host_url.'\' )) AS fileurl, db_file.data_id AS file_data_id FROM db_file	WHERE ((db_file.type = '.ResultsType::Thirteen[XPHEnum::Value].' ) AND (db_file.file_type = '.FileType::File[XPHEnum::Value].')) GROUP BY db_file.data_id) file_view','file_view.file_data_id=db_subject_platform.id');
				$connar['where'] = $this->CI->sqlEscape('db_subject_platform.id=?? ', array($data_id));
				$data=$this->CI->Subject_platform_model->get_single_full($connar);
				// $data=$this->CI->Subject_platform_model->get_single(array('id'=>$data_id));
				break;	
		}

		if(!$data){
			return (retJson('当前成果数据不存在,无法提交考核库',false));
		}


		$data_id = $data['id'];
		unset($data['id']); unset($data['is_submit_kh']);unset($data['is_submit_cg']);unset($data['data_id']);unset($data['img_data_id']); unset($data['file_data_id']);  //移除考核表中不存在的字段
		
		$build_order_no =	$this->build_order_no();
		$data['created'] = date("Y-m-d",$data['created']);
		$admin = $this ->CI-> Admin_model -> get_single(array('id'=>$data['creator']));
		$data['creator'] = $admin['username'];
		//修改成果原表状态
		switch ($type) {
			case ResultsType::First[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'lw_'.$data_id;
				$data['publish_time'] = date("Y-m-d",$data['publish_time']);
				$date_kh_id = $this->CI->Paper_kh_model->add($data);
				$data=$this->CI->Paper_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Second[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'zz_'.$data_id;
				$data['publish_time'] = date("Y-m-d",$data['publish_time']);
				$date_kh_id = $this->CI->Monograph_kh_model->add($data);
				$this->CI->Monograph_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Third[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'zl_'.$data_id;
				$data['announcement_date'] = date("Y-m-d",$data['announcement_date']);
				$data['apply_date'] = date("Y-m-d",$data['apply_date']);
				$date_kh_id = $this->CI->Patent_kh_model->add($data);
				$this->CI->Patent_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Fourth[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'hj_'.$data_id;
				$data['award_time'] = date("Y-m-d",$data['award_time']);
				$date_kh_id = $this->CI->Awards_kh_model->add($data);
				$this->CI->Awards_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Fifth[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'yjbg_'.$data_id;
				$data['submit_date'] = date("Y-m-d",$data['submit_date']);
				$date_kh_id = $this->CI->Research_report_kh_model->add($data);
				$this->CI->Research_report_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Sixth[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'jsbz_'.$data_id;
				$data['publish_time'] = date("Y-m-d",$data['publish_time']);
				$date_kh_id = $this->CI->Technical_standard_kh_model->add($data);
				$this->CI->Technical_standard_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Seventh[XPHEnum::Value]:
				// unset($data['is_submit_cg']);
				$data['uuid'] = 'zxkt_'.$data['number'];
				$data['new_uuid'] = 'zxkt_'.$data_id;
				$data['project_time'] = date("Y-m-d",$data['project_time']);
				$date_kh_id = $this->CI->Vertical_project_kh_model->add($data);
				$this->CI->Vertical_project_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Eighth[XPHEnum::Value]:
				// unset($data['is_submit_cg']);
				$data['uuid'] = 'hxkt_'.$data['number'];
				$data['new_uuid'] = 'hxkt_'.$data_id;
				$data['project_time'] = date("Y-m-d",$data['project_time']);
				$date_kh_id = $this->CI->Horizontal_project_kh_model->add($data);
				$this->CI->Horizontal_project_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Ninth[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'kjzh_'.$data_id;
				$data['time'] = date("Y-m-d",$data['time']);
				$date_kh_id = $this->CI->Science_conversion_kh_model->add($data);
				$this->CI->Science_conversion_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Tenth[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'xsjlh_'.$data_id;
				$data['time'] = date("Y-m-d",$data['time']);
				$date_kh_id = $this->CI->Communication_kh_model->add($data);
				$this->CI->Communication_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Eleventh[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'xsbg_'.$data_id;
				$data['time'] = date("Y-m-d",$data['time']);
				$date_kh_id = $this->CI->Academic_report_kh_model->add($data);
				$this->CI->Academic_report_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			
			case ResultsType::Twelfth[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'xsjz_'.$data_id;
				$data['academia_start'] = date("Y-m-d",$data['academia_start']);
				$data['academia_end'] = date("Y-m-d",$data['academia_end']);
				$date_kh_id = $this->CI->Academia_job_kh_model->add($data);
				$this->CI->Academia_job_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;
			case ResultsType::Thirteen[XPHEnum::Value]:
				$data['number'] = $build_order_no;
				$data['uuid'] = 'xkpt_'.$data_id;
				$data['receive_time'] = date("Y-m-d",$data['receive_time']);
				$date_kh_id = $this->CI->Subject_platform_kh_model->add($data);
				$this->CI->Subject_platform_model->update(array('id'=>$data_id,'is_submit_kh'=>CommonWhether::Whether[XPHEnum::Value]));
				break;	
		}		
		 return array('status'=>true);		

	}	

	//获取随机唯一编号
	public function build_order_no(){
	
		return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
	
	}



	//生成科研业绩编码规则采用32位字母+数字代码 唯一编码,根据不同成果类型传递不同的编码参数
	public function set_only_code($type,$param,$is_old=false){
		switch ($type) {
			case ResultsType::First[XPHEnum::Value]://论文
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位
				if($param['journal_level'] == '其他-英文'){
					$type_code =(new PaperType())->showRemark($param['type']);//论文类型
				}else{
					if(isEnglish($param['journal_name'])){
						if($param['type'] == '中文核心' || $param['type'] == '中文普通'){
							$type_code =(new JournalLevel())->showRemark($param['journal_level']); //刊物级别
						}else{
							$type_code =(new PaperType())->showRemark($param['type']);//论文类型
						}
					}else{
						if($param['journal_level'] == '其他'){
							$type_code =(new JournalLevel())->showRemark($param['journal_level']); 
							$type_code = explode(",",$type_code)[0];
						}else{
							$type_code =(new JournalLevel())->showRemark($param['journal_level']); //刊物级别
						}
					}
				}

				//经费来源第6位
				$ly_code = '9';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
						//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
						//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}
				

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				$cgtype_code = 'a';//ResultsType::First[XPHEnum::Value];
				
				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];
				
				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Paper_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
				
				break;
			
			case ResultsType::Second[XPHEnum::Value]://专著

				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;

				//业绩类型第3-5位 著作类别
				$type_code =(new MonographType())->showRemark($param['type']);
				//经费来源第6位
				$ly_code = '9';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
			    	$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}
				if(!$dept_code){
					$dept_code = '305';
				}
				

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				$cgtype_code = 'b';//ResultsType::Second[XPHEnum::Value];

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Monograph_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
			
				break;
			
			case ResultsType::Third[XPHEnum::Value]://专利
					//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位 著作类别
				$type_code =(new patent_type())->showRemark($param['type']);
				if($type_code == ''){
					$type_code = 'ZL5';
				}

				//经费来源第6位
				$ly_code = '9';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}
				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Third[XPHEnum::Value];
				$cgtype_code = 'c';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Patent_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
			
				break;
			
			case ResultsType::Fourth[XPHEnum::Value]://获奖
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;

				//业绩类型第3-5位 奖励类别
				$award_type = $param['award_type'];
				if($award_type == '获奖论文'){
					switch ($param['award_grade']) {
						case '国家级':
							$type_code = 'LX1';
							break;		
						case '省部级':
							$type_code = 'LX3';
							break;
						case '厅局级':
							$type_code = 'LX5';
							break;
						case '校级':
							$type_code = 'LX7';
							break;
						case '其他':
							$type_code = 'LX9';
							break;
					}
				}elseif($award_type == '科研成果奖'){
					$award_form = $param['award_form'].$param['award_grade'].$param['award_type'];
					if($award_form == '主持国家级科研成果奖'){
						$type_code = 'KC1';
					}elseif($award_form =='参与国家级科研成果奖'){
						$type_code = 'KC2';
					}elseif($award_form =='主持省部级科研成果奖'){
						$type_code = 'KC3';
					}elseif($award_form =='参与省部级科研成果奖'){
						$type_code = 'KC4';
					}elseif($award_form =='主持厅局级科研成果奖'){
						$type_code = 'KC7';
					}elseif($award_form =='参与厅局级科研成果奖'){
						$type_code = 'KC8';
					}else{
						$type_code = 'KC9';
					}
				}else{
					$type_code = 'LX9';
				}

				//经费来源第6位
				$ly_code = '9';
					//业绩部门第7-9位
					if($is_old){
						$dept_code = (new Dept())->showAlternate($param['dept_name']);
						if(!$dept_code){
							$dept_code = (new addDept())->showAlternate($param['dept_name']);
						}
						//查询工号/学号 第10-18位
						$teacher_code = $this->get_usercode($param['author_id']);
					}else{
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
						//查询工号/学号 第10-18位
						$teacher_code = $this->get_usercode($param['author_id'][0]);
					}

					if(!$dept_code){
						$dept_code = '305';
					}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Fourth[XPHEnum::Value];
				$cgtype_code = 'd';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Awards_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}

				break;
			
			case ResultsType::Fifth[XPHEnum::Value]://研究报告
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位 
				$level = $param['level'].$param['type'];

				if($level == '国家级批示'){
					$type_code = 'YP1';
				}elseif($level == '省部级批示'){
					$type_code = 'YP3';
				}elseif($level == '厅局级批示'){
					$type_code = 'YP5';
				}elseif($level == '县区级批示'){
					$type_code = 'YP7';
				}elseif($level == '其他批示'){
					$type_code = 'YP9';
				}elseif($level == '国家级采纳'){
					$type_code = 'YC1';
				}elseif($level == '省部级采纳'){
					$type_code = 'YC3';
				}elseif($level == '厅局级采纳'){
					$type_code = 'YC5';
				}elseif($level == '县区级采纳'){
					$type_code = 'YC7';
				}elseif($level == '其他采纳'){
					$type_code = 'YC9';
				}elseif($level == '国家级其他'){
					$type_code = 'YQ1';
				}elseif($level == '省部级其他'){
					$type_code = 'YQ3';
				}elseif($level == '厅局级其他'){
					$type_code = 'YQ5';
				}elseif($level == '县区级其他'){
					$type_code = 'YQ7';
				}else{
					$type_code = 'YQ9';
				}


				//经费来源第6位
				$ly_code = '9';
					//业绩部门第7-9位
					if($is_old){
						$dept_code = (new Dept())->showAlternate($param['dept_name']);
						if(!$dept_code){
							$dept_code = (new addDept())->showAlternate($param['dept_name']);
						}
						//查询工号/学号 第10-18位
						$teacher_code = $this->get_usercode($param['author_id']);
					}else{
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
						//查询工号/学号 第10-18位
						$teacher_code = $this->get_usercode($param['author_id'][0]);
					}
					if(!$dept_code){
						$dept_code = '305';
					}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Fifth[XPHEnum::Value];
				$cgtype_code = 'e';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Research_report_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
				break;
			
			case ResultsType::Sixth[XPHEnum::Value]://技术标准
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位 
				$technical_type_arr = array();
				foreach ((new technical_type())->getAll() as $k => $v) {
					$technical_type_arr[$v[XPHEnum::Value]] = $v[XPHEnum::Caption];
				}
				if(in_array($param['standard_level'],$technical_type_arr)){
					$type_code =(new technical_type())->showRemark($param['standard_level']);
				}else{
					$type_code = 'JB0';
				}

				//经费来源第6位
				$ly_code = '9';
					//业绩部门第7-9位
					if($is_old){
						$dept_code = (new Dept())->showAlternate($param['dept_name']);
						if(!$dept_code){
							$dept_code = (new addDept())->showAlternate($param['dept_name']);
						}
						//查询工号/学号 第10-18位
						$teacher_code = $this->get_usercode($param['author_id']);
					}else{
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
						//查询工号/学号 第10-18位
						$teacher_code = $this->get_usercode($param['author_id'][0]);
					}

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Sixth[XPHEnum::Value];
				$cgtype_code = 'f';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Technical_standard_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}

				break;
			
			case ResultsType::Seventh[XPHEnum::Value]://纵向

				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;

				//业绩类型第3-5位 
				if($param['level'] == '国家'){
				 	$level_types =	$param['level'].'级'.$param['level_type'];
				}elseif($param['level'] == '国际合作' || $param['level'] == '其他'){
					$level_types =	$param['level'];
				}else{
					$level_types =	$param['level'].$param['level_type'];
				}
		
				$type_code =(new PortraitType())->showRemark($level_types);
				if(!$type_code){
					$type_code = PortraitType::Fourteen[XPHEnum::Remark];
				}
				//经费来源第6位
				$ly_code = '6';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
			    	$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Seventh[XPHEnum::Value];
				$cgtype_code = 'g';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = $param['is_end'];
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Vertical_project_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = $param['is_end'];
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}

				break;
			
			case ResultsType::Eighth[XPHEnum::Value]://横向
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位 
				
				$type_code = PortraitType::Thirteen[XPHEnum::Remark];

				//经费来源第6位
				$ly_code = '8';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
			    	$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Eighth[XPHEnum::Value];
				$cgtype_code = 'h';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code =$param['is_end'];
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Horizontal_project_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = $param['is_end'];
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
				break;
			
			case ResultsType::Ninth[XPHEnum::Value]://转化科技
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;

				//业绩类型第3-5位 
				if($param['form'] == '转让'){
					$type_code = 'KZ1';
				}elseif($param['form'] == '许可'){
					$type_code = 'KZ2';
				}elseif($param['form'] == '作价投资'){
					$type_code = 'KZ3';
				}else{
					$type_code = 'KZ4';
				}

				//经费来源第6位
				$ly_code = '9';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Ninth[XPHEnum::Value];
				$cgtype_code = 'i';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Science_conversion_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
				break;
			
			case ResultsType::Tenth[XPHEnum::Value]://学术交流会
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位 
				if($param['type'] == '主办'){
					$type_code = 'JH1';
				}else if($param['type'] == '承办'){
					$type_code = 'JH2';
				}else if($param['type'] == '协办'){
					$type_code = 'JH4';
				}else if($param['type'] == '参加'){
					$type_code = 'JH5';
				}else if($param['type'] == '学术会议交流'){
					$type_code = 'JH3';
				}else{
					$type_code = 'JH0';
				}

				//经费来源第6位
				$ly_code = '9';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Tenth[XPHEnum::Value];
				$cgtype_code = 'j';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Communication_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
				break;
			
			case ResultsType::Eleventh[XPHEnum::Value]://学术报告
				$cgtype_code = 'k';
				break;
			
			case ResultsType::Twelfth[XPHEnum::Value]://兼职
				$cgtype_code = 'l';
				break;
			case ResultsType::Thirteen[XPHEnum::Value]://学科平台
				//年份第1-2位
				// $year_code = substr(date("Y",strtotime($param['award_year'])), -2) ;
				$year_code = substr($param['award_year'], -2) ;
				//业绩类型第3-5位 
				if($param['platform_level'] == '国家'){
					$type_code = 'XP1';
				}elseif($param['platform_level'] == '国家级分中心'){
					$type_code = 'XP2';
				}elseif($param['platform_level'] == '省部级'){
					$type_code = 'XP3';
				}elseif($param['platform_level'] == '省部级分中心'){
					$type_code = 'XP4';
				}elseif($param['platform_level'] == '厅局级'){
					$type_code = 'XP5';
				}elseif($param['platform_level'] == '校级'){
					$type_code = 'XP6';
				}else{
					$type_code = 'XP7';
				}

				//经费来源第6位
				$ly_code = '9';
				//业绩部门第7-9位
				if($is_old){
					$dept_code = (new Dept())->showAlternate($param['dept_name']);
					if(!$dept_code){
						$dept_code = (new addDept())->showAlternate($param['dept_name']);
					}
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id']);
				}else{
					$dept_code = (new addDept())->showAlternate($param['dept_name']);
					//查询工号/学号 第10-18位
					$teacher_code = $this->get_usercode($param['author_id'][0]);
				}

				if(!$dept_code){
					$dept_code = '305';
				}

				//预留 第19-24位 暂时YLZWZF占位
				$yl_code = 'YLZWZF';

				//成果类型，第25位
				// $cgtype_code = ResultsType::Thirteen[XPHEnum::Value];
				$cgtype_code = 'm';

				//是否科研奖励 第26位
				$isjl_code = $param['is_submit_cg'];

				//随机流水码 第29-32 ,如果是编辑的时候，获取原来的随机码，新增的话，获取4位流水码
				if($param['id'] == 0){						
					//审核状态，第27位
					$issh_code = '0';
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					$random_code =	getRandStr(4);
				}else{
					$data = $this ->CI -> Subject_platform_model -> get_single(array('id'=>$param['id'],'is_del'=>CommonWhether::Not [XPHEnum::Value]));					
					//审核状态，第27位
					$issh_code = $data['status'];
					//是否结题 第28位
					$isjt_code = '0';
					//随机流水码第29-32位
					if($data['only_code'] != ''){
						$new_str = substr($data['only_code'],-4);
						$random_code = $new_str;
					}else{
						$random_code = getRandStr(4);			
					}
				}
				break;	
		}


		//合成最终32位编码，具体规则(学年--业绩类型--经费来源--部门---第一作者/负责人--6位预留占位符--成果类型--是否科研奖励-审核状态--是否结题---4位随机码)
		$newCode = $year_code.$type_code.$ly_code.$dept_code.$teacher_code.$yl_code.$cgtype_code.$isjl_code.$issh_code.$isjt_code.$random_code;

		return $newCode;
	}

	//生成具体的32位编码，
	// public function set_only_code_value($param){
	// 	$param = implode("-",$param);
	// 	var_dump($param);
		
	// }

	//获取工号或学号 ,学号或工号位数不足用9填充
	public function get_usercode($author_id){
		$author = $this->CI -> User_model -> get_single(array("id" => $author_id));
		if($author['type'] == 1 || $author['type'] == 3){ 
			if(is_numeric($author['usercode']) == true && strlen($author['usercode']) == 8){
				$teacher_code = 'G'.trim($author['usercode']);
			}elseif(is_numeric($author['usercode']) == true && strlen($author['usercode']) < 8){
				$length = (8-strlen($author['usercode']));
				$end = '';
				for($i=0;$i<$length;$i++){
					$end .= '9';
				}
				$teacher_code = 'G'.trim($author['usercode']).$end;
			}else{
				$teacher_code = 'G99999999';
			}
		}else{
			//学号如果数值并且有9位的直接取，如果小于九位，则后面缺几位用9填充，如果不是数组，直接9位都用9填充
			if(is_numeric($author['usercode']) == true && strlen($author['usercode']) == 9){
				$teacher_code = trim($author['usercode']) ; 
			}else if(is_numeric($author['usercode']) == true && strlen($author['usercode']) < 9){
				$length = (9-strlen($author['usercode']));
				$end = '';
				for($i=0;$i<$length;$i++){
					$end .= '9';
				}
				$teacher_code = trim($author['usercode']).$end ;
			}else{
				$teacher_code = '999999999';
				// $teacher_code = date("Ymd",time()).rand(0,9);
			}
		}
		return $teacher_code;
	}

	//解析32位编码
	public function analysis_only_code_value($code){
		//分解编码
		$rest = array();
		$rest['year_code'] = substr($code,0,2); //第1-2位 年份
		$rest['type_code'] = substr($code,2,3);//第3-5位 业绩类型
		$rest['ly_code'] = substr($code,5,1); //第6位 经费来源
		$rest['dept_code'] = substr($code,6,3);//第7-9位 部门
		$rest['teacher_code'] = substr($code,9,9);//第10-18位 工号/学号
		$rest['yl_code'] = substr($code,18,6); //第19-24位 预留占位
		$rest['cgtype_code'] = substr($code,24,1);//第25位 成果类型
		$rest['isjl_code'] = substr($code,25,1);//第26位 是否成果奖励
		$rest['issh_code'] = substr($code,26,1);//第27位 是否审核
		$rest['isjt_code'] = substr($code,27,1);//第28位 是否结题
		$rest['random_code'] = substr($code,28,4);//最后四位  随机码
		return $rest;
	}


	//根据编码查询成果
	public function selectProject($type,$param){
		$data = array();
		$connar = array();
		switch($type){
			case ResultsType::First[XPHEnum::Remark];
				     $connar = $this->CI -> Paper_kh_model -> pickPages($connar, $param);
				break;

			case ResultsType::Second[XPHEnum::Remark]:
					$connar=$this->CI->Monograph_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Third[XPHEnum::Remark]:
					$connar=$this->CI->Patent_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Fourth[XPHEnum::Remark]:
					$connar=$this->CI->Awards_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Fifth[XPHEnum::Remark]:
					$connar=$this->CI->Research_kh_report_model-> pickPages($connar, $param);
			
			case ResultsType::Sixth[XPHEnum::Remark]:
					$connar=$this->CI->Technical_kh_standard_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Seventh[XPHEnum::Remark]:
					$connar=$this->CI->Vertical_kh_project_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Eighth[XPHEnum::Remark]:
					$connar=$this->CI->Horizontal_project_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Ninth[XPHEnum::Remark]:
					$connar=$this->CI->Science_conversion_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Tenth[XPHEnum::Remark]:
					$connar=$this->CI->Communication_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Eleventh[XPHEnum::Remark]:
					$connar=$this->CI->Academic_report_kh_model-> pickPages($connar, $param);
				break;
			
			case ResultsType::Twelfth[XPHEnum::Remark]:
					$connar=$this->CI->Academia_job_kh_model-> pickPages($connar, $param);
				break;
			case ResultsType::Thirteen[XPHEnum::Remark]:
					$connar=$this->CI->Subject_platform_kh_model-> pickPages($connar, $param);
				break;

		}
	

		// array('only_code'=>$only_code,'is_del'=>CommonWhether::Not [XPHEnum::Value])
	   $connar['where']=$this->CI->sqlEscape('is_del=?? ',array(CommonWhether::Not [XPHEnum::Value]));
	   //唯一编码搜索
	   if(isset($param['code']) && $param['code'] != '' && $param['code'] != null){
		  $connar['where'] .= $this->CI->sqlEscape(' and only_code=?? ',array($param['code']));
	   }
	   //标题
	   if(isset($param['title']) && $param['title'] != '' && $param['title'] != null){
		  $connar['where'] .=  " and name like '%".$param['title']."%'";
	    }

		//业绩归属年份
		if(isset($param['award_year']) && $param['award_year'] != '' && $param['award_year'] != null){
			$connar['where'] .= $this->CI->sqlEscape(' and award_year=?? ',array($param['award_year']));
		}

		switch ($type) {
			case ResultsType::First[XPHEnum::Remark]:
				$data=$this->CI->Paper_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::First[XPHEnum::Caption];
				break;
			
			case ResultsType::Second[XPHEnum::Remark]:
				$data=$this->CI->Monograph_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Second[XPHEnum::Caption];
				break;
			
			case ResultsType::Third[XPHEnum::Remark]:
				$data=$this->CI->Patent_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Third[XPHEnum::Caption];
				break;
			
			case ResultsType::Fourth[XPHEnum::Remark]:
				$data=$this->CI->Awards_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Fourth[XPHEnum::Caption];
				break;
			
			case ResultsType::Fifth[XPHEnum::Remark]:
				$data=$this->CI->Research_kh_report_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Fifth[XPHEnum::Caption];
				break;
			
			case ResultsType::Sixth[XPHEnum::Remark]:
				$data=$this->CI->Technical_kh_standard_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Sixth[XPHEnum::Caption];
				break;
			
			case ResultsType::Seventh[XPHEnum::Remark]:
				$data=$this->CI->Vertical_kh_project_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Seventh[XPHEnum::Caption];
				break;
			
			case ResultsType::Eighth[XPHEnum::Remark]:
				$data=$this->CI->Horizontal_project_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Eighth[XPHEnum::Caption];
				break;
			
			case ResultsType::Ninth[XPHEnum::Remark]:
				$data=$this->CI->Science_conversion_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Ninth[XPHEnum::Caption];
				break;
			
			case ResultsType::Tenth[XPHEnum::Remark]:
				$data=$this->CI->Communication_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Tenth[XPHEnum::Caption];
				break;
			
			case ResultsType::Eleventh[XPHEnum::Remark]:
				$data=$this->CI->Academic_report_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Eleventh[XPHEnum::Caption];
				break;
			
			case ResultsType::Twelfth[XPHEnum::Remark]:
				$data=$this->CI->Academia_job_kh_model->get_page_list($connar);
				$data['cg_type'] = ResultsType::Twelfth[XPHEnum::Caption];
				break;

			case ResultsType::Thirteen[XPHEnum::Remark]:
				$data=$this->CI->Subject_platform_kh_model->get_page_list($connar);
				if($data){
					$data['cg_type'] = ResultsType::Thirteen[XPHEnum::Caption];
				}
				break;	
		}

	
		
		return $data;
	}


	//修改老数据code
	public function set_old_code($type){
		//论文
		$connar['where']=$this->CI->sqlEscape('is_del=?? and only_code is null',array(CommonWhether::Not [XPHEnum::Value]));

		 switch ($type) {
			 case ResultsType::First[XPHEnum::Remark]:
				$connar['items']= '	db_paper.id,`name`,author1.author_id,author1.author_name,journal_name,journal_level,publish_time,db_paper.type,dept_name,award_year,is_submit_cg,status,only_code';
				$connar['groupby']= 'db_paper.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::First[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_paper.id');
				 $data=$this->CI->Paper_model->get_list_full($connar);
				//  echo $this->CI->db->last_Query();
				// var_dump($data);
				if($data){
					foreach($data as $k=>&$v){
						if(isEnglish($v['journal_name'])){
							$v['journal_level'] = '其他-英文';
						}else{
							$v['journal_level'] = '其他';
						}
						$get_code = $this->set_only_code(1, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Paper_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('lw_'.$v['id']));
						$kh = $this->CI->Paper_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Paper_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				
				 break;
			 
			 case ResultsType::Second[XPHEnum::Remark]:
				$connar['items']= '	db_monograph.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_monograph.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Second[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_monograph.id');
				 $data=$this->CI->Monograph_model->get_list_full($connar);
				 if($data){
					foreach($data as $k=>&$v){
						if($v['type'] == ''){
							$v['type'] = '其他';
						}
						$get_code = $this->set_only_code(2, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Monograph_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('zz_'.$v['id']));
						$kh = $this->CI->Monograph_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Monograph_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Third[XPHEnum::Remark]:
				$connar['items']= '	db_patent.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_patent.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Third[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_patent.id');
				 $data=$this->CI->Patent_model->get_list_full($connar);
				 if($data){
					foreach($data as $k=>&$v){
						if($v['type'] == ''){
							$v['type'] = '其他';
						}elseif($v['type'] == '实用新型'){
							$v['type'] = '实用新型专利';
						}

						$get_code = $this->set_only_code(3, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Patent_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('zl_'.$v['id']));
						$kh = $this->CI->Patent_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Patent_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Fourth[XPHEnum::Remark]:
				$connar['items']= '	db_awards.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_awards.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Fourth[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_awards.id');
				 $data=$this->CI->Awards_model->get_list_full($connar);
				//  echo $this->CI->db->last_query();exit;
				 if($data){
					foreach($data as $k=>&$v){
					
						$get_code = $this->set_only_code(4, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Awards_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('hj_'.$v['id']));
						$kh = $this->CI->Awards_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Awards_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}

				 break;
			 
			 case ResultsType::Fifth[XPHEnum::Remark]:
				$connar['items']= '	db_research_report.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_research_report.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Fifth[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_research_report.id');
				 $data=$this->CI->Research_report_model->get_list_full($connar);
				//  echo $this->CI->db->last_query();exit;
				 if($data){
					foreach($data as $k=>&$v){
						if($v['level'] == '市局、县（区）级政府' || $v['level'] = '得到县处级现职领导肯定性批示'||$v['level'] == '县处级' || $v['level'] =='县级 '){
							$v['level'] = '县区级';
						}else if($v['level'] == '市级' || $v['level'] == '嘉兴市委'||$v['level'] == '绍兴市商务局'||$v['level'] == '市厅级'||$v['level'] == '局级'||$v['level'] == '绍兴市商务局' || $v['level']=='厅局级'){
							$v['level'] = '厅局级';
						}else if($v['level'] == '省部级'){
							$v['level'] = '省部级';
						}else if($v['level'] == '被县（区）级党委政府或处级部门采纳'){
							$v['level'] = '县区级';
						}else if($v['level'] == '被市人大、政协采纳' || $v['level'] == '被市局、县（区）党委或政府采纳'){
							$v['level'] = '厅局级';
						}else if($v['level'] == '行业'){
							$v['level'] = '其他';
						}

						if($v['type'] == '调研报告'){
							$v['type'] = '其他';
						}
					
						$get_code = $this->set_only_code(5, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Research_report_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('yjbg_'.$v['id']));
						$kh = $this->CI->Research_report_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Research_report_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Sixth[XPHEnum::Remark]:
				$connar['items']= '	db_technical_standard.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_technical_standard.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Sixth[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_technical_standard.id');
				 $data=$this->CI->Technical_standard_model->get_list_full($connar);

				 if($data){
					foreach($data as $k=>&$v){
						if($v['standard_level'] == '企业标准' || $v['standard_level'] == '企业级' || $v['standard_level'] == '高新技术企业标准'){
							$v['standard_level'] = '企业技术标准';

						}else{
							$v['standard_level'] = '其他';
						}
						
						$get_code = $this->set_only_code(6, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Technical_standard_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('jsbz_'.$v['id']));
						$kh = $this->CI->Technical_standard_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Technical_standard_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Seventh[XPHEnum::Remark]:
				$connar['items']= '	db_vertical_project.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_vertical_project.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Seventh[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_vertical_project.id');
				 $data=$this->CI->Vertical_project_model->get_list_full($connar);
				//  echo $this->CI->db->last_query();exit;
				 if($data){
					foreach($data as $k=>&$v){	
						$get_code = $this->set_only_code(7, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Vertical_project_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('new_uuid=?? ', array('zxkt_'.$v['id']));
						$kh = $this->CI->Vertical_project_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Vertical_project_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Eighth[XPHEnum::Remark]:
				$connar['items']= '	db_horizontal_project.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_horizontal_project.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Eighth[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_horizontal_project.id');
				 $data=$this->CI->Horizontal_project_model->get_list_full($connar);

				 if($data){
					foreach($data as $k=>&$v){
					
						$get_code = $this->set_only_code(8, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Horizontal_project_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('new_uuid=?? ', array('hxkt_'.$v['id']));
						$kh = $this->CI->Horizontal_project_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Horizontal_project_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Ninth[XPHEnum::Remark]:
				$connar['items']= '	db_science_conversion.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_science_conversion.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Ninth[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_science_conversion.id');
				 $data=$this->CI->Science_conversion_model->get_list_full($connar);
				//  echo $this->CI->db->last_query();exit;
				 if($data){
					foreach($data as $k=>&$v){
					
						$get_code = $this->set_only_code(9, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Science_conversion_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('kjzh_'.$v['id']));
						$kh = $this->CI->Science_conversion_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Science_conversion_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Tenth[XPHEnum::Remark]:
				$connar['items']= '	db_communication.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_communication.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Tenth[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_communication.id');
				 $data=$this->CI->Communication_model->get_list_full($connar);
				//  echo $this->CI->db->last_query();exit;
				 if($data){
					foreach($data as $k=>&$v){
						if($v['type']== ''){
							$v['type'] == '学术会议交流';
						}
					
						$get_code = $this->set_only_code(10, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Communication_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('xsjlh_'.$v['id']));
						$kh = $this->CI->Communication_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Communication_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;
			 
			 case ResultsType::Eleventh[XPHEnum::Remark]:
				 $data=$this->CI->Academic_report_model->get_list_full($connar);
				 break;
			 
			 case ResultsType::Twelfth[XPHEnum::Remark]:
				 $data=$this->CI->Academia_job_model->get_list_full($connar);
				 break;
			 case ResultsType::Thirteen[XPHEnum::Remark]:
				$connar['items']= '	db_subject_platform.*,author1.author_id,author1.author_name';
				$connar['groupby']= 'db_subject_platform.name';
				$connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Thirteen[XPHEnum::Value].' order by id asc) author1','author1.data_id=db_subject_platform.id');
				 $data=$this->CI->Subject_platform_model->get_list_full($connar);
				//  echo $this->CI->db->last_query();exit;
				 if($data){
					foreach($data as $k=>&$v){
					
						$get_code = $this->set_only_code(13, $v,true);
	
						$param['only_code'] = $get_code;
						$param['id'] = $v['id'];
						$this ->CI-> Subject_platform_model -> update($param,'id');
	
						$connar1['where'] = $this->CI->sqlEscape('uuid=?? ', array('xkpt_'.$v['id']));
						$kh = $this->CI->Subject_platform_kh_model->get_single_full($connar1);
						if($kh){
							$param1['only_code'] = $get_code;
							$param1['id'] = $kh ['id'];
							$this->CI->Subject_platform_kh_model->update($param1,'id'); //修改考核库
						}
	
					}	
				}
				 break;	
		 }

		 return true;

	}
	
}